<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
  <head>
    
    <title>修改员工</title>
<head>
  <div th:replace="~{commons/script::script}"></div>
    <title>修改员工信息</title>
    <style type="text/css">
.tl{
	width:100px;
	text-align: right;
	background-color: #ddd
}
.tc{
	width: 50px
}

input{
	width: 170px;
	height: 32px
}
td{
	height: 30px;
	font-size: 14px
}

</style>

</head>
  
<body>
	<div style="padding-left: 30px">
	<form id="form" method="post">
			<br><p style="color:#0a0;font-size: 16px;margin-left: 150px;margin-top: 10px">添加员工信息</p><br>
			<hr style="margin-right: 30px"><br>
		<table cellspacing="10" cellpadding="0" style="margin-left: 70px">
			<tr>
				<td class="tl">员工姓名:<input type="hidden" th:value="${employee.id}" name="id"></td>
				<td><input type="text" name="name" class="easyui-textbox theme-textbox-radius"
						   data-options="required:true" th:value="${employee.name}"></td>
			</tr>
			<tr>
				<td class="tl">岗位：</td>
				<td class="text-content">
					<select name="positionId" class="easyui-combobox theme-textbox-radius" style="width:150px">
<!--						<option value="0">&#45;&#45;请选择&#45;&#45;</option>-->
						<option th:each="position:${positions}" th:value="${position.id}" th:text="${position.name}"
						th:selected="${employee.positionId==position.id?true:false}"></option>
					</select>
				</td>
			</tr>
			<tr>
				<td class="tl">状态：</td>
				<td class="text-content">
					<select name="status" class="easyui-combobox theme-textbox-radius" style="width:150px">
						<option value="1" th:selected="${employee.status==1?true:false}">激活</option>
						<option value="0" th:selected="${employee.status==0?true:false}">未激活</option>
					</select>
				</td>
			</tr>
			<tr>
				<td class="tl">对应的用户：</td>
				<td class="text-content">
					<select name="userId" class="easyui-combobox theme-textbox-radius" style="width:150px">...
						<option th:each="user:${users}" th:value="${user.id}"
								th:text="${user.username}" th:selected="${user.id==employee.userId?true:false}"></option>
					</select>
				</td>
			</tr>
			<tr>
<!--				<td class="tl">性别:</td>-->
<!--				<td><input type="text" class="easyui-textbox theme-textbox-radius" data-options="required:true" name="telephone"></td>-->
				<td class="tl">性别：</td>
				<td>
					<input type="radio" name="sex" value="1" style="width:50px;height: 20px" th:checked="${employee.sex==1?true:false}">男
					<input type="radio" value="0" name="sex" style="width:50px;height: 20px" th:checked="${employee.sex==0?true:false}">女
				</td>
			</tr>
			<tr>
				<td class="tl">联系电话:</td>
				<td><input type="text" th:value="${employee.telephone}" class="easyui-textbox theme-textbox-radius" data-options="required:true" name="telephone"></td>
			</tr>
			<tr>
				<td class="tl">邮箱:</td>
				<td><input type="text" th:value="${employee.email}" name="email"  class="easyui-textbox theme-textbox-radius"></td>
			</tr>
			<tr>
				<td class="tl">地址:</td>
				<td><input name="address" th:value="${employee.address}" class="easyui-textbox theme-textbox-radius"></td>
			</tr>

			<tr>
				<td colspan="2px" style="text-align: center">
					<a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-primary">保存</a>&nbsp; &nbsp;&nbsp;&nbsp;
					<a href="javascript:void(0);" id="resetBtn" class="easyui-linkbutton button-danger">重置</a>
				</td>
			</tr>
    </table>	
    </form>
    </div>
	<script type="text/javascript">
		$(function() {
			//重置按钮
			$("#resetBtn").on("click",function(event){
				$("#form").form("reset");
			});
			
			//为保存按钮添加事件
			$("#saveBtn").on("click",function(event){
				$("#form").form("submit",{
					url:"/employee/updateEmployee",
					onSumbit : function(){
						//调用easyui中form对象的validate方法对表单中数据进行校验，该方法返回boolean值，如果为false会阻止表单提交
						return $("#form").form("validate");
					},
					success : function(data){
						data = eval("(" + data + ")");
						if(data.success){
							$.messager.alert("提示",data.message);
							parent.closeTopWindow();
						}else{
							$.messager.alert("警告",data.message);
						}
					}
				});
			});
			
		});
			
	</script>
</body>
</html>
